package com.hxwm.hwdbtool.core;

import com.hxwm.hwdbtool.util.HwUtil;

/**
 * @program: hwdbtool
 * @ClassName HwException
 * @description:
 * @author: hxwm
 * @create: 2024-06-02 10:19
 * @Version 1.0
 **/
public class HwException extends Exception {

    private String exceptionCode;
    private String exceptionMessage;

    public HwException(AppHttpCodeEnum appHttpCodeEnum){
        super();
        this.exceptionCode = appHttpCodeEnum.getCode();
        this.exceptionMessage = appHttpCodeEnum.getMessage();
    }
    public HwException(String exceptionStr) {
        super(exceptionStr);
        if(!HwUtil.isNullOrEmpty(exceptionStr)){
            this.exceptionCode = exceptionStr.substring(0,exceptionStr.lastIndexOf("|"));
            this.exceptionMessage = exceptionStr.substring(exceptionStr.lastIndexOf("|")+1);
        }else{
            this.exceptionCode = AppHttpCodeEnum.SYSTEM_ERROR.getCode();
            this.exceptionMessage = AppHttpCodeEnum.SYSTEM_ERROR.getMessage();
        }
        //log.error("ErrorInfo:" + this.exceptionCode + "|" + this.exceptionMessage);
    }
    public HwException(String exceptionCode, String exceptionMessage) {
        super();
        this.exceptionCode = exceptionCode;
        this.exceptionMessage = exceptionMessage;
    }

    public HwException(String message, Throwable cause, String exceptionCode, String exceptionMessage) {
        super(message, cause);
        this.exceptionCode = exceptionCode;
        this.exceptionMessage = exceptionMessage;
    }

    public String getExceptionCode() {
        return exceptionCode;
    }

    public void setExceptionCode(String exceptionCode) {
        this.exceptionCode = exceptionCode;
    }

    public String getExceptionMessage() {
        return exceptionMessage;
    }

    public void setExceptionMessage(String exceptionMessage) {
        this.exceptionMessage = exceptionMessage;
    }
}